﻿using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Utilities
{
    public class ExceptionHelper
    {
        public static HttpResponseException CreateHttpResponseException(string reason)
        {
            var response = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.BadRequest,
                ReasonPhrase = reason,
                Content = new StringContent(reason)
            };
            return new HttpResponseException(response);
        }

        public static HttpResponseException CreateHttpResponseException(string reason, Exception e)
        {
            Utility.LogEx(e.Message, e);

            return CreateHttpResponseException(reason);
        }
    }
}